'''
@project:NewDream
@auther:ZhouQi
@file:request_datas.py
@date:2022/11/21 17:15
@desc:
'''
import pytest
import requests
from  common.config import config
#获取token
@pytest.fixture()
def get_access_token():
    token_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential"
    param = {"appid": "wx688c435964125192", "secret": "538e779f5baf13b8d1195bb5ef5a6526"}
    res = requests.get(url=token_url, params=param)
    token_data=res.json()  #创建一个json对象
    return token_data['access_token']   #取出token_data的access_token

@pytest.fixture(params=['4','5','6'])
def create_tag_name(request):
    creat_tag = {  # 创建标签
        "url_create": "https://%s/cgi-bin/tags/create" % config.Host,
        "param": {"access_token": get_access_token()},
        "data_create": {"tag": {"name": "tagName"+request.param}}  #request.param就是代表request获取上面的params的值
    }
    return creat_tag



class RequestDatas():
    # token="63_01BIzhyO6Mai5Tc9JPrUQtbQMluo_4bYE0XNS2pUfU9cNmIA0TOe08A8U1kn_flpaxH_gjGEo46-CHfX_BpxSfxop5Ub79K1p4bzE6DSO_Z6shY_eE0DEPsqXd4YHNaAGAMVB"

    get_tags={  #获取所有已创建的标签名
        "tagNames_url" : "https://api.weixin.qq.com/cgi-bin/tags/get",
        "param" : {"access_token": "token"}
    }
    edit_tag={  #编辑标签名
        "edit_url":"https://api.weixin.qq.com/cgi-bin/tags/update",
        "param":{"access_token": "token"},
        "edit_data":{"tag":{"id":"101","name":"吃火锅组3"}}
    }
    all_fans = {  #获取标签下所有粉丝列表
        "all_fans_url": "https://api.weixin.qq.com/cgi-bin/user/tag/get",
        "param": {"access_token": "token"},
        "all_fans_data": {   "tagid" : "101",   "next_openid":""}
    }
    tagNumber_user = {  # 批量为用户打标签
        "tagNumbeUsers_url": "https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging",
        "param": {"access_token": "token"},
        "tagNumberUser_data": {
            "openid_list" : [
            "oCm1z6CsNdsDEDZswuclrInjCACk",
            "oCm1z6Dg4ey_7m_2qgot5hrf5QuI"   ],
            "tagid" : "101"}
    }
    cancel_tagNumber = {  # 批量为用户取消标签
        "cancelTags_rul": "https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging",
        "param": {"access_token": "token"},
        "cancelTags_data": {
            "openid_list" : [
            "oCm1z6CsNdsDEDZswuclrInjCACk",
            "oCm1z6Dg4ey_7m_2qgot5hrf5QuI"   ],
            "tagid" : "101"}
    }
    User_tagsList = {  # 获取用户身上的标签列表
        "tagsList_rul": "https://api.weixin.qq.com/cgi-bin/tags/getidlist",
        "param": {"access_token": "token"},
        "tagsList_data":{   "openid" : "oCm1z6GOwX17Mp6M4fH6B9CrhNbk" }
    }
    delete_tags = {  # 删除标签
        "delete_rul": "https://api.weixin.qq.com/cgi-bin/tags/delete",
        "param": {"access_token": "token"},
        "delete_data": {   "tag":{        "id" : "123"   } }
    }